package edu.fdzc.project.exception;

import edu.fdzc.project.common.Code;
import edu.fdzc.project.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result<Object> handleException(Exception e) {
        e.printStackTrace();
        return Result.error(Code.INTERNAL_SERVER_ERROR, "系统错误");
    }

    @ExceptionHandler(CustomException.class)
    public Result<Object> handleCustomException(CustomException e) {
        e.printStackTrace();
        return Result.error(e.getCode(), e.getMsg());
    }

}
